package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Chat;
import cn.wolfcode.trip.base.domain.ChatRecord;
import cn.wolfcode.trip.base.mapper.ChatMapper;
import cn.wolfcode.trip.base.mapper.ChatRecordMapper;
import cn.wolfcode.trip.base.service.IChatRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatRecordServiceImpl implements IChatRecordService {

    @Autowired
    private ChatMapper chatMapper;

    @Autowired
    private ChatRecordMapper chatRecordMapper;

    @Override
    public List<ChatRecord> queryForList(Chat chat) {
        Chat theChat = chatMapper.queryBySenderIdAndReceiverId(chat);
        if (theChat != null) {
            return chatRecordMapper.selectForList(theChat.getId());
        }
        return null;
    }
}
